package com.lowca.news.web.formbean;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.ScriptAssert;

@ScriptAssert.List({ @ScriptAssert(lang = "javascript", script = "_this.confirmPassword.equals(_this.password)", message = "重复密码与密码不相等") })
public class RegisterForm {

	@NotEmpty
	@Length(min = 6, max = 16)
	@Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]+$", message = "用户名格式不正确")
	private String username;
	@NotEmpty
	@Length(min = 6, max = 16)
	@Pattern(regexp = "^[\\@A-Za-z0-9\\!\\#\\$\\%\\^\\&\\*\\.\\~]+$", message = "密码格式不正确")
	private String password;
	private String confirmPassword;
	@NotEmpty
	@Email
	private String email;
	@NotEmpty
	private String captcha;
	@AssertTrue(message = "必须同意注册协议")
	private boolean agreement;
	private String backUrl;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCaptcha() {
		return captcha;
	}

	public void setCaptcha(String captcha) {
		this.captcha = captcha;
	}

	public boolean isAgreement() {
		return agreement;
	}

	public void setAgreement(boolean agreement) {
		this.agreement = agreement;
	}

	public String getBackUrl() {
		return backUrl;
	}

	public void setBackUrl(String backUrl) {
		this.backUrl = backUrl;
	}

}
